
import Mock from 'mockjs' //引入mockjs，npm已安装

let Random = Mock.Random
// 使用mockjs模拟数据
// Mock.mock('/IssueList','post',issueList)
//Mock.mock('/IssueList','post',list)


let addList = function(opt)
{
    let id = parseInt(JSON.parse(opt.body).params.id)
    console.log(id)
    return
    {
        data:id
    }
}
Mock.mock('/Report','post',addList)


let arr = []
for (let i = 0; i < 30; i++) {
    let newArticleObject = {
        name: Random.cname(), // Random.cname() 随机生成一个常见的中文姓名
        content: Random.csentence(5, 30), // Random.csentence( min, max )
        id: i
    }
    arr.push(newArticleObject);
}
let list = function (options) {
    let rtype = options.type.toLowerCase(); //获取请求类型
    switch (rtype) {
        case 'get':
            break;
        case 'post':
            let id = parseInt(JSON.parse(options.body).params.id) //获取删除的id
            arr = arr.filter(function(val){
                return val.id!=id;//把这个id对应的对象从数组里删除
            });
            break;
        default:
    }
    return {
        data: arr
    } //返回这个数组,也就是返回处理后的假数据
}
Mock.mock('/IssueList', /get|post/i, list);




